import 'package:flutter/material.dart';
import 'dart:math';
import 'dart:io';
import '../models/exam_model.dart';
import '../models/question_model.dart';
import '../utils/responsive_util.dart';
import '../services/student_service.dart';
import '../models/student_model.dart';

class AnswerDetailsScreen extends StatefulWidget {
  final Exam exam;
  final ExamResult result;
  final bool isAdminView;
  
  const AnswerDetailsScreen({
    super.key,
    required this.exam,
    required this.result,
    this.isAdminView = false,
  });

  @override
  State<AnswerDetailsScreen> createState() => _AnswerDetailsScreenState();
}

class _AnswerDetailsScreenState extends State<AnswerDetailsScreen> {
  int _currentIndex = 0;
  late PageController _pageController;
  Student? _student;

  @override
  void initState() {
    super.initState();
    _pageController = PageController();
    if (widget.isAdminView) {
      _loadStudentInfo();
    }
  }

  Future<void> _loadStudentInfo() async {
    if (!widget.isAdminView) return;
    
    try {
      await StudentService.init();
      final students = StudentService.getStudents();
      
      for (var student in students) {
        if (student.id == widget.result.userId) {
          setState(() {
            _student = student;
          });
          break;
        }
      }
    } catch (e) {
      debugPrint('加载学生信息失败: $e');
    }
  }

  @override
  void dispose() {
    _pageController.dispose();
    super.dispose();
  }

  // 获取问题得分
  int _getQuestionScore(String questionId) {
    return widget.result.scores[questionId] ?? 0;
  }

  // 判断问题是否答对
  bool _isQuestionCorrect(String questionId) {
    final int score = _getQuestionScore(questionId);
    final Question question = widget.exam.questions.firstWhere((q) => q.id == questionId);
    
    // 如果已有分数，直接使用分数判断是否正确
    if (widget.result.scores.containsKey(questionId)) {
      return score >= question.score;
    }
    
    // 如果是主观题（如简答题），且有上传照片，视为有效作答
    if (question.type == QuestionType.shortAnswer) {
      final bool hasPhotoAnswer = (widget.result.answerImages[questionId]?.isNotEmpty ?? false);
      if (hasPhotoAnswer) {
        // 对于有照片的简答题，我们暂时假设它是正确的，因为需要人工评分
        // 这里只是标记为"已作答"状态，而不是"错误"状态
        return true;
      }
    }
    
    return score >= question.score;
  }

  // 获取用户答案的显示文本
  String _getUserAnswerText(Question question) {
    final dynamic userAnswer = widget.result.answers[question.id];
    final List<String> photoAnswers = widget.result.answerImages[question.id] ?? [];
    
    // 如果有照片答案，显示照片信息
    String photoInfo = '';
    if (photoAnswers.isNotEmpty) {
      photoInfo = '【已提交${photoAnswers.length}张照片答案】';
    }
    
    if (userAnswer == null && photoAnswers.isEmpty) {
      return '未作答';
    } else if (userAnswer == null && photoAnswers.isNotEmpty) {
      return photoInfo;
    }
    
    switch (question.type) {
      case QuestionType.singleChoice:
        var q = question as SingleChoiceQuestion;
        String selectedOptionId = userAnswer.toString();
        // 查找选择的选项文本
        try {
          Choice selectedChoice = q.choices.firstWhere((c) => c.id == selectedOptionId);
          return '${selectedChoice.id}. ${selectedChoice.text}';
        } catch (e) {
          return selectedOptionId;
        }
        
      case QuestionType.multipleChoice:
        var q = question as MultipleChoiceQuestion;
        if (userAnswer is List && userAnswer.isNotEmpty) {
          List<String> selectedOptions = List<String>.from(userAnswer.map((e) => e.toString()));
          List<String> optionTexts = [];
          
          for (String optionId in selectedOptions) {
            try {
              Choice choice = q.choices.firstWhere((c) => c.id == optionId);
              optionTexts.add('${choice.id}. ${choice.text}');
            } catch (e) {
              optionTexts.add(optionId);
            }
          }
          
          return optionTexts.join('\n');
        }
        return '未选择任何选项${photoAnswers.isNotEmpty ? '\n$photoInfo' : ''}';
        
      case QuestionType.fillBlank:
        return '${userAnswer.toString()}${photoAnswers.isNotEmpty ? '\n$photoInfo' : ''}';
        
      case QuestionType.trueOrFalse:
        return '${userAnswer == true ? '正确' : '错误'}${photoAnswers.isNotEmpty ? '\n$photoInfo' : ''}';
        
      case QuestionType.shortAnswer:
        String textAnswer = userAnswer.toString();
        // 如果文字答案为空或非常短，且有照片，优先展示照片信息
        if ((textAnswer.isEmpty || textAnswer.length < 5) && photoAnswers.isNotEmpty) {
          return photoInfo;
        }
        // 否则同时显示文字和照片信息
        return '${textAnswer}${photoAnswers.isNotEmpty ? '\n$photoInfo' : ''}';
    }
  }

  // 获取正确答案的显示文本
  String _getCorrectAnswerText(Question question) {
    switch (question.type) {
      case QuestionType.singleChoice:
        var q = question as SingleChoiceQuestion;
        if (q.correctOption >= 0 && q.correctOption < q.choices.length) {
          Choice correctChoice = q.choices[q.correctOption];
          return '${correctChoice.id}. ${correctChoice.text}';
        }
        return '答案索引错误';
        
      case QuestionType.multipleChoice:
        var q = question as MultipleChoiceQuestion;
        List<String> correctTexts = [];
        
        for (int index in q.correctOptions) {
          if (index >= 0 && index < q.choices.length) {
            Choice choice = q.choices[index];
            correctTexts.add('${choice.id}. ${choice.text}');
          }
        }
        
        return correctTexts.isNotEmpty ? correctTexts.join('\n') : '未设置正确答案';
        
      case QuestionType.fillBlank:
        var q = question as FillBlankQuestion;
        return q.correctAnswer;
        
      case QuestionType.trueOrFalse:
        var q = question as TrueOrFalseQuestion;
        return q.correctAnswer ? '正确' : '错误';
        
      case QuestionType.shortAnswer:
        var q = question as ShortAnswerQuestion;
        return q.referencedAnswer;
    }
  }

  // 获取问题的答案分析
  String _getAnswerAnalysisText(Question question) {
    // 优先使用Question对象上的analysis属性
    if (question.analysis != null && question.analysis!.isNotEmpty) {
      return question.analysis!;
    }
    
    // 调试输出所有questionAnalysis数据
    if (widget.exam.questionAnalysis != null) {
      debugPrint("所有答案分析数据: ${widget.exam.questionAnalysis}");
      
      // 遍历所有答案分析，查找是否有匹配此题目ID的分析
      widget.exam.questionAnalysis!.forEach((key, value) {
        debugPrint("答案分析项: key=$key, value=$value");
      });
    } else {
      debugPrint("exam.questionAnalysis为空");
    }
    
    // 如果问题对象上没有答案分析，则从exam的questionAnalysis映射中查找
    if (widget.exam.questionAnalysis != null) {
      String? analysis = widget.exam.questionAnalysis![question.id];
      if (analysis != null && analysis.isNotEmpty) {
        return analysis;
      }
      
      // 如果通过ID精确匹配没找到，尝试部分匹配
      for (var entry in widget.exam.questionAnalysis!.entries) {
        if (entry.key.contains(question.id) || question.id.contains(entry.key)) {
          debugPrint("通过部分匹配找到答案分析: ${entry.key} -> ${entry.value}");
          return entry.value;
        }
      }
    }
    
    // 如果都没有找到，返回默认文本
    return '暂无答案分析';
  }

  @override
  Widget build(BuildContext context) {
    final bool isTablet = ResponsiveUtil.isTablet(context);
    
    return WillPopScope(
      onWillPop: () async {
        // 直接返回，没有需要保存的状态
        Navigator.of(context).pop();
        return false; // 我们自己处理导航，所以返回false
      },
      child: Scaffold(
        appBar: AppBar(
          title: Text(
            widget.isAdminView ? '学生答题详情' : '答案详情',
            style: TextStyle(
              fontSize: 18.0,
              fontWeight: FontWeight.bold,
              color: Colors.white,
            ),
          ),
          backgroundColor: Colors.blue.shade800,
          foregroundColor: Colors.white,
          leading: IconButton(
            icon: Icon(Icons.arrow_back),
            onPressed: () => Navigator.of(context).pop(),
          ),
        ),
        body: Column(
          children: [
            // 如果是管理员视图，显示学生信息
            if (widget.isAdminView) _buildStudentInfoHeader(),
            
            // 进度指示器
            LinearProgressIndicator(
              value: (_currentIndex + 1) / widget.exam.questions.length,
              backgroundColor: Colors.grey.shade200,
              valueColor: AlwaysStoppedAnimation<Color>(Colors.blue.shade800),
              minHeight: 3,
            ),
            
            // 问题计数器
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    '问题 ${_currentIndex + 1}/${widget.exam.questions.length}',
                    style: TextStyle(
                      fontSize: 14.0,
                      fontWeight: FontWeight.bold,
                      color: Colors.grey.shade800,
                    ),
                  ),
                  Row(
                    children: [
                      IconButton(
                        icon: Icon(Icons.arrow_back_ios, size: 16),
                        onPressed: _currentIndex > 0 
                            ? () {
                                _pageController.previousPage(
                                  duration: const Duration(milliseconds: 300),
                                  curve: Curves.easeInOut,
                                );
                              }
                            : null,
                        color: Colors.blue.shade800,
                        disabledColor: Colors.grey.shade400,
                        constraints: BoxConstraints(
                          minWidth: 36,
                          minHeight: 36,
                        ),
                        padding: EdgeInsets.zero,
                        splashRadius: 24,
                      ),
                      IconButton(
                        icon: Icon(Icons.arrow_forward_ios, size: 16),
                        onPressed: _currentIndex < widget.exam.questions.length - 1 
                            ? () {
                                _pageController.nextPage(
                                  duration: const Duration(milliseconds: 300),
                                  curve: Curves.easeInOut,
                                );
                              }
                            : null,
                        color: Colors.blue.shade800,
                        disabledColor: Colors.grey.shade400,
                        constraints: BoxConstraints(
                          minWidth: 36,
                          minHeight: 36,
                        ),
                        padding: EdgeInsets.zero,
                        splashRadius: 24,
                      ),
                    ],
                  ),
                ],
              ),
            ),
            
            // 详细答案区域
            Expanded(
              child: PageView.builder(
                controller: _pageController,
                onPageChanged: (index) {
                  setState(() {
                    _currentIndex = index;
                  });
                },
                itemCount: widget.exam.questions.length,
                itemBuilder: (context, index) {
                  final question = widget.exam.questions[index];
                  return _buildQuestionDetailPage(question, isTablet);
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
  
  // 构建学生信息头部（仅管理员视图使用）
  Widget _buildStudentInfoHeader() {
    return Container(
      padding: EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: Colors.blue.shade50,
        border: Border(
          bottom: BorderSide(
            color: Colors.blue.shade100,
            width: 1,
          ),
        ),
      ),
      child: Row(
        children: [
          CircleAvatar(
            backgroundColor: Colors.blue.shade200,
            radius: 24,
            child: Text(
              _student?.name.substring(0, 1) ?? '?',
              style: TextStyle(
                fontSize: 20,
                fontWeight: FontWeight.bold,
                color: Colors.white,
              ),
            ),
          ),
          SizedBox(width: 16),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    Text(
                      _student?.name ?? '未知学生',
                      style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    Text(
                      ' (${widget.result.userId})',
                      style: TextStyle(
                        fontSize: 14,
                        color: Colors.grey.shade700,
                      ),
                    ),
                    SizedBox(width: 8),
                    Container(
                      padding: EdgeInsets.symmetric(horizontal: 8, vertical: 2),
                      decoration: BoxDecoration(
                        color: widget.result.totalScore >= (widget.exam.totalScore * 0.6)
                            ? Colors.green.shade100
                            : Colors.red.shade100,
                        borderRadius: BorderRadius.circular(12),
                      ),
                      child: Text(
                        widget.result.totalScore >= (widget.exam.totalScore * 0.6)
                            ? '通过'
                            : '未通过',
                        style: TextStyle(
                          fontSize: 12,
                          fontWeight: FontWeight.bold,
                          color: widget.result.totalScore >= (widget.exam.totalScore * 0.6)
                              ? Colors.green.shade800
                              : Colors.red.shade800,
                        ),
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 4),
                Text(
                  '得分: ${widget.result.totalScore}/${widget.exam.totalScore} (${(widget.result.totalScore / widget.exam.totalScore * 100).toStringAsFixed(1)}%)',
                  style: TextStyle(
                    fontSize: 14,
                    color: Colors.blue.shade800,
                  ),
                ),
                SizedBox(height: 4),
                Text(
                  '提交时间: ${widget.result.submittedAt != null ? 
                      '${widget.result.submittedAt!.year}-${widget.result.submittedAt!.month}-${widget.result.submittedAt!.day} ${widget.result.submittedAt!.hour}:${widget.result.submittedAt!.minute}' : 
                      '未知'}',
                  style: TextStyle(
                    fontSize: 12,
                    color: Colors.grey.shade700,
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
  
  // 构建问题详情页面
  Widget _buildQuestionDetailPage(Question question, bool isTablet) {
    final bool isCorrect = _isQuestionCorrect(question.id);
    
    return SingleChildScrollView(
      padding: EdgeInsets.all(16.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 问题状态指示器
          Row(
            children: [
              Container(
                padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
                decoration: BoxDecoration(
                  color: isCorrect ? Colors.green.shade100 : Colors.red.shade100,
                  borderRadius: BorderRadius.circular(16),
                  border: Border.all(
                    color: isCorrect ? Colors.green : Colors.red,
                    width: 1,
                  ),
                ),
                child: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Icon(
                      isCorrect ? Icons.check_circle : Icons.cancel,
                      color: isCorrect ? Colors.green : Colors.red,
                      size: 16,
                    ),
                    SizedBox(width: 4),
                    Text(
                      isCorrect ? '正确' : '错误',
                      style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.bold,
                        color: isCorrect ? Colors.green.shade800 : Colors.red.shade800,
                      ),
                    ),
                  ],
                ),
              ),
              SizedBox(width: 8),
              Container(
                padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
                decoration: BoxDecoration(
                  color: Colors.orange.shade100,
                  borderRadius: BorderRadius.circular(16),
                  border: Border.all(
                    color: Colors.orange,
                    width: 1,
                  ),
                ),
                child: Text(
                  '得分: ${_getQuestionScore(question.id)}/${question.score}',
                  style: TextStyle(
                    fontSize: 14,
                    fontWeight: FontWeight.bold,
                    color: Colors.orange.shade800,
                  ),
                ),
              ),
            ],
          ),
          
          SizedBox(height: 16),
          
          // 问题类型和内容
          Container(
            padding: EdgeInsets.all(16),
            decoration: BoxDecoration(
              color: Colors.blue.shade50,
              borderRadius: BorderRadius.circular(12),
              border: Border.all(color: Colors.blue.shade100),
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  _getQuestionTypeText(question.type),
                  style: TextStyle(
                    fontSize: 14,
                    fontWeight: FontWeight.bold,
                    color: Colors.blue.shade800,
                  ),
                ),
                SizedBox(height: 8),
                Text(
                  question.text,
                  style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ),
          
          SizedBox(height: 16),
          
          // 用户答案
          _buildAnswerSection(
            title: widget.isAdminView ? '学生答案' : '你的答案',
            content: _getUserAnswerText(question),
            correct: isCorrect,
          ),
          
          SizedBox(height: 16),
          
          // 用户上传的答题照片
          _buildAnswerPhotosSection(question.id),
          
          // 正确答案
          SizedBox(height: 16),
          
          _buildAnswerSection(
            title: '正确答案',
            content: _getCorrectAnswerText(question),
            isReference: true,
          ),
          
          // 答案分析
          SizedBox(height: 16),
          _buildAnswerSection(
            title: '答案分析',
            content: _getAnswerAnalysisText(question),
            isReference: true,
            isAnalysis: true,
          ),
          
          // 对于选择题，显示所有选项
          if (question is ChoiceQuestion) ...[
            SizedBox(height: 16),
            _buildAllOptionsSection(question),
          ],
        ],
      ),
    );
  }
  
  // 构建答案部分
  Widget _buildAnswerSection({
    required String title,
    required String content,
    bool correct = false,
    bool isReference = false,
    bool isAnalysis = false,
  }) {
    Color backgroundColor = isAnalysis
        ? Colors.purple.shade50
        : (isReference
            ? Colors.blue.shade50
            : (correct ? Colors.green.shade50 : Colors.red.shade50));
    
    Color borderColor = isAnalysis
        ? Colors.purple.shade200
        : (isReference
            ? Colors.blue.shade200
            : (correct ? Colors.green.shade200 : Colors.red.shade200));
    
    Color titleColor = isAnalysis
        ? Colors.purple.shade800
        : (isReference
            ? Colors.blue.shade800
            : (correct ? Colors.green.shade800 : Colors.red.shade800));
    
    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: backgroundColor,
        borderRadius: BorderRadius.circular(8),
        border: Border.all(color: borderColor),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              if (isAnalysis) Icon(Icons.lightbulb, size: 16, color: titleColor),
              if (isAnalysis) SizedBox(width: 4),
              Text(
                title,
                style: TextStyle(
                  fontSize: 14,
                  fontWeight: FontWeight.bold,
                  color: titleColor,
                ),
              ),
            ],
          ),
          SizedBox(height: 8),
          Text(
            content,
            style: TextStyle(
              fontSize: 16,
            ),
          ),
        ],
      ),
    );
  }
  
  // 构建所有选项部分（针对选择题）
  Widget _buildAllOptionsSection(ChoiceQuestion question) {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: Colors.grey.shade50,
        borderRadius: BorderRadius.circular(8),
        border: Border.all(color: Colors.grey.shade300),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '所有选项',
            style: TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.bold,
              color: Colors.grey.shade800,
            ),
          ),
          SizedBox(height: 8),
          ...question.choices.map((choice) {
            bool isCorrect = false;
            
            if (question is SingleChoiceQuestion) {
              isCorrect = question.correctOption < question.choices.length &&
                  question.choices[question.correctOption].id == choice.id;
            } else if (question is MultipleChoiceQuestion) {
              for (int index in question.correctOptions) {
                if (index < question.choices.length && 
                    question.choices[index].id == choice.id) {
                  isCorrect = true;
                  break;
                }
              }
            }
            
            return Container(
              margin: EdgeInsets.only(bottom: 8),
              padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
              decoration: BoxDecoration(
                color: isCorrect ? Colors.green.shade50 : Colors.white,
                borderRadius: BorderRadius.circular(8),
                border: Border.all(
                  color: isCorrect ? Colors.green.shade300 : Colors.grey.shade300,
                ),
              ),
              child: Row(
                children: [
                  if (isCorrect)
                    Icon(Icons.check_circle, color: Colors.green, size: 16),
                  SizedBox(width: isCorrect ? 8 : 0),
                  Expanded(
                    child: Text(
                      '${choice.id}. ${choice.text}',
                      style: TextStyle(
                        fontSize: 14,
                        fontWeight: isCorrect ? FontWeight.bold : FontWeight.normal,
                      ),
                    ),
                  ),
                ],
              ),
            );
          }).toList(),
        ],
      ),
    );
  }
  
  // 构建答题照片部分
  Widget _buildAnswerPhotosSection(String questionId) {
    // 获取当前题目的答题照片
    final List<String> photos = widget.result.answerImages[questionId] ?? [];
    
    if (photos.isEmpty) {
      return SizedBox.shrink(); // 如果没有照片，不显示此部分
    }
    
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          width: double.infinity,
          padding: EdgeInsets.all(16),
          decoration: BoxDecoration(
            color: Colors.amber.shade50,
            borderRadius: BorderRadius.circular(8),
            border: Border.all(color: Colors.amber.shade200),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  Icon(Icons.photo_library, size: 16, color: Colors.amber.shade800),
                  SizedBox(width: 4),
                  Text(
                    '答题照片',
                    style: TextStyle(
                      fontSize: 14,
                      fontWeight: FontWeight.bold,
                      color: Colors.amber.shade800,
                    ),
                  ),
                ],
              ),
              SizedBox(height: 12),
              Container(
                height: 200,
                child: GridView.builder(
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    crossAxisSpacing: 8,
                    mainAxisSpacing: 8,
                  ),
                  itemCount: photos.length,
                  itemBuilder: (context, index) {
                    return GestureDetector(
                      onTap: () => _showFullScreenImage(photos[index]),
                      child: Container(
                        decoration: BoxDecoration(
                          border: Border.all(color: Colors.grey.shade300),
                          borderRadius: BorderRadius.circular(8),
                        ),
                        child: ClipRRect(
                          borderRadius: BorderRadius.circular(8),
                          child: Image.file(
                            File(photos[index]),
                            fit: BoxFit.cover,
                            errorBuilder: (context, error, stackTrace) {
                              return Center(
                                child: Icon(
                                  Icons.error_outline,
                                  color: Colors.red.shade400,
                                  size: 32,
                                ),
                              );
                            },
                          ),
                        ),
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
        SizedBox(height: 16),
      ],
    );
  }
  
  // 显示全屏图片
  void _showFullScreenImage(String imagePath) {
    Navigator.of(context).push(
      MaterialPageRoute(
        builder: (context) => Scaffold(
          backgroundColor: Colors.black,
          appBar: AppBar(
            backgroundColor: Colors.black,
            foregroundColor: Colors.white,
            title: Text('答题照片'),
            elevation: 0,
          ),
          body: Center(
            child: InteractiveViewer(
              minScale: 0.5,
              maxScale: 3.0,
              child: Image.file(
                File(imagePath),
                fit: BoxFit.contain,
                errorBuilder: (context, error, stackTrace) {
                  return Center(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Icon(
                          Icons.error_outline,
                          color: Colors.red.shade400,
                          size: 64,
                        ),
                        SizedBox(height: 16),
                        Text(
                          '无法加载图片',
                          style: TextStyle(color: Colors.white),
                        ),
                      ],
                    ),
                  );
                },
              ),
            ),
          ),
        ),
        settings: RouteSettings(name: 'FullScreenImage'),
      ),
    );
  }
  
  // 获取问题类型文本
  String _getQuestionTypeText(QuestionType type) {
    switch (type) {
      case QuestionType.singleChoice:
        return '单选题';
      case QuestionType.multipleChoice:
        return '多选题';
      case QuestionType.fillBlank:
        return '填空题';
      case QuestionType.trueOrFalse:
        return '判断题';
      case QuestionType.shortAnswer:
        return '简答题';
    }
  }
} 